package com.tengju.support.domain.model.alert;


import com.tengju.support.domain.shared.CastUtil;
import com.tengju.support.domain.shared.DomainEvent;

public class AlertEvent implements DomainEvent<AlertEvent> {

    String title;
    StringBuilder msg;

    @Override
    public boolean sameEventAs(AlertEvent other) {
        return false;
    }

    public AlertEvent(String title) {
        this.title = title;
        this.msg = new StringBuilder();
    }

    public AlertEvent(String title, StringBuilder msg) {
        this.title = title;
        this.msg = msg;
    }

    public void addItem(String itemTitle, Object itemMsg) {
        msg.append(itemTitle)
                .append(":")
                .append(CastUtil.castString(itemMsg))
                .append("\n");
    }

    public String getTitle() {
        return title;
    }

    public String getMsg() {
        return msg.toString();
    }

    @Override
    public String toString() {
        return "AlertEvent{" +
                "title='" + title + '\'' +
                ", msg=" + msg +
                '}';
    }
}
